package com.framework.modules.job.task;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.framework.entity.ter.TerMerchantReport;
import com.framework.service.ActiveService;
import com.framework.service.DistribuService;
import com.framework.service.MerchantService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * 功能描述: 拉卡拉宝盒每月返现 80
 *
 * @author ck
 * @date 2018/11/21 10:03
 */
@Component("baoHeRep")
public class BaoHeRepTask {
	private Logger logger = LoggerFactory.getLogger(getClass());

	@Autowired
	private MerchantService merchantService;

	@Autowired
	private DistribuService distribuService;


	//每天通用终端激活返现定时器
	public void addBaoHeRep(){
		logger.debug("===============拉卡拉宝盒返现定时器开始==============");
		//刷爆激活返现

		List<TerMerchantReport> reports = merchantService.selectList(new EntityWrapper<TerMerchantReport>().eq("dept_id", 889326L));

		for (TerMerchantReport report : reports) {
			Long agentId = distribuService.queryTerminalOwn(report.getSn());

			if(!agentId.equals(report.getAgentId())){
					distribuService.disTerminal(report.getSn(),report.getAgentId(),report.getDeptId());
			}


		}

		logger.debug("===============拉卡拉宝盒返现定时器结束==============");
	}
}
